package com.hsfw.pmauthzuul.controller;

import com.hsfw.dbmodule.entity.UserDetail;
import com.hsfw.dbmodule.entity.UserToken;
import com.hsfw.dbmodule.utils.BaseResponse;
import com.hsfw.pmauthzuul.service.impl.AuthServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
public class LoginController {
    @Autowired
    AuthServiceImpl authService;

    @PostMapping("/login")
    public BaseResponse login(@RequestParam(value = "uname", required = true) String uname,
                              @RequestParam(value = "pwd", required = true) String pwd) {
        UserToken uk = authService.login(uname, pwd);
        BaseResponse baseResponse;
        baseResponse = BaseResponse.buildResponse().setObj(uk).build();
        return baseResponse;
    }
    @PostMapping("/register")
    public BaseResponse register(@RequestBody UserDetail userDetail){

        BaseResponse baseResponse;
        baseResponse=BaseResponse.buildResponse().setObj("").build();
        return baseResponse;
    }
}
